package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoGalleryDetailsType;
import com.muyu.danmo.service.IDanmoGalleryDetailsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 画廊与类型关联Controller
 *
 * @author yangle
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/galleryDetailsType")
public class DanmoGalleryDetailsTypeController extends BaseController
{
    @Autowired
    private IDanmoGalleryDetailsTypeService danmoGalleryDetailsTypeService;

    /**
     * 查询画廊与类型关联列表
     */
//    @RequiresPermissions("system:galleryDetailsType:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoGalleryDetailsType>> list(DanmoGalleryDetailsType danmoGalleryDetailsType)
    {
        startPage();
        List<DanmoGalleryDetailsType> list = danmoGalleryDetailsTypeService.selectDanmoGalleryDetailsTypeList(danmoGalleryDetailsType);
        return getDataTable(list);
    }

    /**
     * 导出画廊与类型关联列表
     */
//    @RequiresPermissions("system:galleryDetailsType:export")
    @Log(title = "画廊与类型关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoGalleryDetailsType danmoGalleryDetailsType)
    {
        List<DanmoGalleryDetailsType> list = danmoGalleryDetailsTypeService.selectDanmoGalleryDetailsTypeList(danmoGalleryDetailsType);
        ExcelUtil<DanmoGalleryDetailsType> util = new ExcelUtil<DanmoGalleryDetailsType>(DanmoGalleryDetailsType.class);
        util.exportExcel(response, list, "画廊与类型关联数据");
    }

    /**
     * 获取画廊与类型关联详细信息
     */
//    @RequiresPermissions("system:galleryDetailsType:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoGalleryDetailsTypeService.selectDanmoGalleryDetailsTypeById(id));
    }

    /**
     * 新增画廊与类型关联
     */
//    @RequiresPermissions("system:galleryDetailsType:add")
    @Log(title = "画廊与类型关联", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoGalleryDetailsType danmoGalleryDetailsType)
    {
        return toAjax(danmoGalleryDetailsTypeService.insertDanmoGalleryDetailsType(danmoGalleryDetailsType));
    }

    /**
     * 修改画廊与类型关联
     */
//    @RequiresPermissions("system:galleryDetailsType:edit")
    @Log(title = "画廊与类型关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoGalleryDetailsType danmoGalleryDetailsType)
    {
        return toAjax(danmoGalleryDetailsTypeService.updateDanmoGalleryDetailsType(danmoGalleryDetailsType));
    }

    /**
     * 删除画廊与类型关联
     */
//    @RequiresPermissions("system:galleryDetailsType:remove")
    @Log(title = "画廊与类型关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoGalleryDetailsTypeService.deleteDanmoGalleryDetailsTypeByIds(ids));
    }
}
